<!--
 * @Description: 流程图
 * @Author: wangwangwang
 * @Date: 2020-12-18 09:52:25
 * @LastEditors: wangwangwang
 * @LastEditTime: 2020-12-18 11:44:15
-->
<template>
  <el-dialog v-dialogDrag width="90%" title="流程图" :before-close="hanldeClose" :visible.sync="visible">
    <div class="map-container">
      <div v-for="(item, index) in dataSource" :key="item.id" class="flow-list">
        <div v-if="index!==(dataSource.length-1)" class="flow-line">
          <div class="arrow-icon"></div>
        </div>
        <div v-for="(list, index2) in item.instanceLogsList" :key="index2" class="node-container">
          <div v-if="index2!==0" class="node-line1"></div>
          <div v-if="index2!==0" class="node-line2"></div>
          <div v-if="index2!==0" class="node-line3">
            <div class="arrow-icon"></div>
          </div>
          <div v-if="index2!==0" class="node-line4"></div>
          <div v-if="index===0" class="start-node">开始</div>
          <div v-if="index!==0&&index!==(dataSource.length-1)" class="node-list">{{list.userName}}</div>
          <div v-if="index===(dataSource.length-1)" class="end-node">
            <div class="circle-bot">
              <div class="circle">
                <div>
                  结束
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button class="bottom_all_two" @click="hanldeClose">关闭</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  props: ["visible", 'nodeDataSource'],
  data () {
    return {
      dataSource: [],
    }
  },
  watch: {
    visible (value) {
      if (value) {
        this.dataSource = this.nodeDataSource;
        console.log(this.dataSource)
      }
    }
  },
  methods: {
    hanldeClose() {
      this.$emit("closeModel");
    },
  }
}
</script>
<style scoped lang="scss">
.start-node{
  width: 50px;
  height: 50px;
  line-height: 50px;
  border-radius: 50%;
  background: #3f8e4d;
  text-align: center;
  font-size: 14px;
  color: #fff;
  position: relative;
  left: 50px;
  cursor: pointer;
}
.end-node{
  border-radius: 50%;
  text-align: center;
  font-size: 14px;
  position: relative;
  left: 45px;
  .circle-bot {
    border-radius: 50%;
    height: 60px;
    width: 60px;
    background-color: #f8f2ed;
    display: flex;
    justify-content: center;
    align-items: center;
    .circle {
      border-radius: 50%;
      height: 50px;
      width: 50px;
      background-color: #f4e1cd;
      display: flex;
      justify-content: center;
      align-items: center;
      > div {
        border-radius: 50%;
        height: 40px;
        width: 40px;
        line-height: 40px;
        background-color: #e29b4c;
        color: #ffffff;
        text-align: center;
      }
    }
  }
}
.node-container{
  padding-right: 30px;
  position: relative;
  .node-list{
    background: #dbdbdc;
    width: 150px;
    height: 50px;
    text-align: center;
    line-height: 50px;
    border-radius: 10px;
    font-size: 14px;
    color: #fff;
    cursor: pointer;
  }
  .node-line1{
    position: absolute;
    width: 100%;
    height: 2px;
    background: #4fad59;
    top: -25px;
    left: -105px;
  }
  .node-line2{
    position: absolute;
    width: 100%;
    height: 2px;
    background: #4fad59;
    bottom: -25px;
    left: -105px;
  }
  .node-line3{
    position: absolute;
    width: 2px;
    height: 20px;
    background: #4fad59;
    top: -25px;
    left: 75px;
    .arrow-icon{
      position: absolute;
      bottom: -5px;
      width: 0;
      height: 0;
      border-left: 5px solid transparent;
      border-right: 5px solid transparent;
      border-top: 10px solid #4fad59;
      left: -4px;
    }
  }
  .node-line4{
    position: absolute;
    width: 2px;
    height: 25px;
    background: #4fad59;
    bottom: -25px;
    left: 75px;
  }
}
.flow-list{
  display: flex;
  padding-bottom: 50px;
  position: relative;
  .flow-line{
    position: absolute;
    height: calc(100% - 50px);
    width: 2px;
    background: #4fad59;
    bottom: 5px;
    left: 75px;
    .arrow-icon{
      position: absolute;
      bottom: -5px;
      width: 0;
      height: 0;
      border-left: 5px solid transparent;
      border-right: 5px solid transparent;
      border-top: 10px solid #4fad59;
      left: -4px;
    }
  }
}
</style>
